package Controler;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
 
public class TestDate { // ANNEE - MOIS - JOUR
 
    public static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
 
    public static Date stringToDate(String sDate) throws ParseException {
        return formatter.parse(sDate);
    }
 
    public static Timestamp toDBDateFormat(String sDate) throws ParseException {
        return new Timestamp(stringToDate(sDate).getTime());
    }
 
    public static String dateToString(Date date) {
        return formatter.format(date);
 
    }
 // Tester la date
    public static void main(String[] args) throws ParseException {
        String inputDate = "2013-01-16";
        Date d=stringToDate(inputDate);
        System.out.println(dateToString(d));
    }
 
}